package com.util;

import java.util.Arrays;
import java.util.List;
import java.util.concurrent.TimeUnit;

/**
 * @author: sun.hongliang
 * @create: 2019/05/30 10:40
 */
public class FragmentFactory {

    public static <T extends Frament> T getFrament(Class<T> clazz, String str) throws IllegalAccessException, InstantiationException {
        Frament frament = clazz.newInstance();
        frament.setArgument(str);
        return (T) frament;
    }

    public static void main(String[] args) throws InstantiationException, IllegalAccessException {
        final long l = TimeUnit.MILLISECONDS.toMinutes(125398);
        final List<Class<? extends Frament>> classes = Arrays.asList(A.class, Frament.class);
        for(Class<? extends Frament> clazz : classes){
            Frament frament = FragmentFactory.getFrament(clazz, "");
            System.out.println(frament);
        }
        System.out.println(l);
    }
}

class A extends Frament {
    private String kk;

    @Override
    public String toString() {
        return "A{" +
                "kk='" + kk + '\'' +
                '}';
    }
}